package com.liuyucheng.concurrent.waitnotify;

public class Producer implements Runnable {
    private Message message;

    public Producer(Message message) {
        this.message = message;
    }

    @Override
    public void run() {
        String[] messages = {
                "消息1",
                "消息2",
                "消息3",
                "结束"
        };

        for (String msg : messages) {
            message.send(msg);

            // 模拟生产耗时
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            }
        }
    }
}